<template>
  <view class="drugs-container">
    <!-- 顶部标题 -->
    <view class="header">
      <text class="back-btn" @click="goBack">‹</text>
      <text class="header-title">药品查询购买</text>
    </view>

    <!-- 搜索框 -->
    <view class="search-section">
      <view class="search-box">
        <text class="search-icon">🔍</text>
        <input 
          type="text" 
          placeholder="输入您想搜索的药品"
          class="search-input"
          v-model="searchKeyword"
        />
      </view>
    </view>

    <!-- 药品列表 -->
    <view class="drug-list">
      <view class="drug-item" v-for="drug in drugList" :key="drug.id" @click="viewDrugDetail(drug)">
        <view class="drug-icon">
          <image :src="drug.image" class="drug-image" />
        </view>
        <view class="drug-info">
          <view class="drug-name">{{ drug.name }}</view>
          <view class="drug-tags">
            <text class="tag">{{ drug.category }}</text>
            <text class="tag">{{ drug.type }}</text>
          </view>
        </view>
        <view class="drug-action">
          <button class="purchase-btn" @click.stop="purchaseDrug(drug)">
            购买
          </button>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'DrugsPurchasePage',
  data() {
    return {
      searchKeyword: '',
      drugList: [
        {
          id: 1,
          name: '叉黄芪苷内眼释胶囊',
          category: '解热清热',
          type: '头痛',
          image: '/static/images/drug1.png'
        },
        {
          id: 2,
          name: '天和温感膏',
          category: '解热清热',
          type: '清热',
          image: '/static/images/drug2.png'
        },
        {
          id: 3,
          name: '仿退压膏',
          category: '去湿',
          type: '西药',
          image: '/static/images/drug3.png'
        },
        {
          id: 4,
          name: '云南白药膏',
          category: '解热清热',
          type: '外药',
          image: '/static/images/drug4.png'
        }
      ]
    }
  },
  methods: {
    goBack() {
      uni.navigateBack()
    },

    viewDrugDetail(drug) {
      uni.showToast({
        title: `查看${drug.name}详情`,
        icon: 'none'
      })
    },

    purchaseDrug(drug) {
      uni.showToast({
        title: `购买${drug.name}`,
        icon: 'none'
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.drugs-container {
  min-height: 100vh;
  background: #f5f5f5;
}

// 顶部标题
.header {
  display: flex;
  align-items: center;
  padding: 40rpx 32rpx;
  background: white;
  position: relative;
}

.back-btn {
  font-size: 48rpx;
  color: #4CAF50;
  position: absolute;
  left: 32rpx;
}

.header-title {
  flex: 1;
  text-align: center;
  font-size: 36rpx;
  font-weight: 500;
  color: #333;
}

// 搜索区域
.search-section {
  padding: 32rpx;
  background: white;
  margin-bottom: 20rpx;
}

.search-box {
  display: flex;
  align-items: center;
  background: #f5f5f5;
  border-radius: 25rpx;
  padding: 20rpx 32rpx;
}

.search-icon {
  font-size: 32rpx;
  color: #999;
  margin-right: 16rpx;
}

.search-input {
  flex: 1;
  font-size: 28rpx;
  color: #333;
  background: transparent;
  border: none;
}

// 药品列表
.drug-list {
  padding: 0 32rpx;
}

.drug-item {
  background: white;
  border-radius: 16rpx;
  padding: 32rpx;
  margin-bottom: 20rpx;
  display: flex;
  align-items: center;
}

.drug-icon {
  width: 100rpx;
  height: 100rpx;
  background: #e3f2fd;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 24rpx;
}

.drug-image {
  width: 60rpx;
  height: 60rpx;
  border-radius: 50%;
}

.drug-info {
  flex: 1;
}

.drug-name {
  font-size: 32rpx;
  font-weight: 500;
  color: #333;
  margin-bottom: 16rpx;
}

.drug-tags {
  display: flex;
  gap: 16rpx;
}

.tag {
  padding: 6rpx 16rpx;
  background: #e8f5e8;
  color: #4CAF50;
  border-radius: 16rpx;
  font-size: 22rpx;
}

.drug-action {
  
}

.purchase-btn {
  padding: 16rpx 32rpx;
  background: #9E9E9E;
  color: white;
  border: none;
  border-radius: 20rpx;
  font-size: 24rpx;
}
</style>